<?php
class Home_m extends CI_Model{
	function __construct(){
		parent :: __construct();
		$this->load->database();
	}
      function check_exist_record(){
  $query =
    $this->db->select()
       ->from("home")
       ->order_by("id", "ASC")
       ->limit(1)
       ->get();
  if($query->num_rows()>0){
   return $query;
  }else{
   return false;
  }

 }
  //--add content to db--//
 function add_home_content($data){
  $query =
   $this->db->insert("home", $data);

  return $query;
 }

 //--load home content--//
 function load_home_content($id){
  $query=
   $this->db->select()
      ->from("home")
      ->where("id", $id)
      ->order_by("id", "ASC")
      ->limit(1)
      ->get();
  if($query->num_rows()>0){
   return $query;
  }else{
   return FALSE;
  }
 }

 //--edit home information--//
 function edit_home_content($id, $data){
  $query = $this->db->update("home", $data, array("id"=>$id));
  return $query;
 }
 
function get_content($table){
    return $this->db->get($table)->row_array();
}
function get_contact(){
    $this->db->select();
    $this->db->from('contact');
     $this->db->order_by('id','ASC');
    return $this->db->get()->result_array();
}
function get_contact_info(){
  return $this->db->get('site_information')->row_array();
}
function get_studio(){
      $this->db->select();
    $this->db->from('studio');
     $this->db->order_by('name','ASC');
    return $this->db->get()->result_array();
}
function get_client(){
      $this->db->select();
    $this->db->from('client');
     $this->db->order_by('name','ASC');
    return $this->db->get()->result_array();
}

function get_img_client(){
     $this->db->select();
    $this->db->from('client_image');
     $this->db->order_by('id','ASC');
    return $this->db->get()->result_array();
}
function get_partner_link(){
     $this->db->select();
    $this->db->from('link');
     $this->db->where('kind','partner');
     $this->db->order_by('id','ASC');
    return $this->db->get()->result_array();
}
function get_event_link(){
     $this->db->select();
    $this->db->from('link');
     $this->db->join('link_category','link.cat_id=link_category.id');
     $this->db->where('link.kind','event');
     $this->db->order_by('link_category.id','ASC');
    return $this->db->get()->result_array();
}
function get_description_link(){
     $this->db->select();
    $this->db->from('event_description');
    return $this->db->get()->row_array();
}
}